﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using curbside.Extensions;
using System.Xml;
using Newtonsoft.Json;
using System.Xml.Linq;

namespace curbside.Extensions
{
    public class JsonString : BaseString
    {
        public JsonString(string s) : base(s) { }
    }

    public static class JsonStringExtensions
    {
        public static XmlNode ToXmlNode(this JsonString s)
        {
            return JsonConvert.DeserializeXmlNode(s.Value);
        }

        public static XmlNode ToXmlNode(this JsonString s, string deserializeRootElementName)
        {
            return JsonConvert.DeserializeXmlNode(s.Value, deserializeRootElementName);
        }

        public static XmlNode ToXmlNode(this JsonString s, string deserializeRootElementName, bool writeArrayAttribute)
        {
            return JsonConvert.DeserializeXmlNode(s.Value, deserializeRootElementName, writeArrayAttribute);
        }

        public static XDocument ToXNode(this JsonString s)
        {
            return JsonConvert.DeserializeXNode(s.Value);
        }

        public static XDocument ToXNode(this JsonString s, string deserializeRootElementName)
        {
            return JsonConvert.DeserializeXNode(s.Value, deserializeRootElementName);
        }

        public static XDocument ToXNode(this JsonString s, string deserializeRootElementName, bool writeArrayAttribute)
        {
            return JsonConvert.DeserializeXNode(s.Value, deserializeRootElementName, writeArrayAttribute);
        }
    }
}
